import pygame

class Camera:
    """Camera module for simple manage views """
    def __init__(self, rect):
        """init camera """
        self.rect=rect
        
    def SetSize(self, newsize):
        """set new size (width,height)"""
        self.rect.w=newsize[0]
        self.rect.h=newsize[1]
    
    def GetSize(self):
        """get current size """
        return (self.rect.w, self.rect.h)
    
    def GetRect(self):
        """return pygame.Rect() from size and position"""
        return self.rect
    
    def MoveCamera(self, offsetx, offsety):
        """move camera by given offset"""
        self.rect.move_ip(offsetx, offsety)
    
    def CenterAt(self, position):
        """Center camera at position point"""
        self.rect.center=position
        
    def PointInCamera(self, point):
        """check is point in camera? """
        return self.rect.collidepoint(point)
    
    def RectInCamera(self, rect):
        """check is rect in camera ? (portion). rect=(posx,posy,width,height)"""
        return self.rect.colliderect(rect)
